package mc747.portal.logicas;

import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import mc747.portal.servlet.Logica;
import mc747.servicos.autenticacao.Builder;
import mc747.servicos.autenticacao.Retorno;

public class Login implements Logica {

	public void executa(HttpServletRequest req, HttpServletResponse res)
			throws Exception {
		// Falta colocar as chamadas do web services aqui
		String password = req.getParameter("password");
		String email = req.getParameter("email");
		Retorno r = Builder.login(password, email);
		if (r.getErro() != null) {
			req.setAttribute("erro", r.getErro());
			RequestDispatcher rd = req.getRequestDispatcher(req.getParameter("fwdFail"));
			rd.forward(req, res);
		}
		else{
			RequestDispatcher rd = req.getRequestDispatcher(req.getParameter("fwdSuccess"));
			rd.forward(req, res);
		}

	}

}
